package com.example.demo.service.impl;


import com.example.demo.mapper.ShiroUserMapper;
import com.example.demo.mapper.UserMapper;
import com.example.demo.pojo.ShiroUser;
import com.example.demo.pojo.User;
import com.example.demo.service.User.ShiroUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * shiro用户服务impl
 *
 * @author yzh
 * @date 2022/11/25
 */
@Service
public class ShiroUserServiceImpl implements ShiroUserService {
    @Autowired
    ShiroUserMapper shiroUserMapper;

    @Override
    public ShiroUser queryUserByName(String name) {
        return shiroUserMapper.queryUserByName(name);

    }

    public void Shiro_registered(ShiroUser shiroUser) throws InterruptedException {
        System.out.println(shiroUser.getName());
        Thread thread = new Thread(new Task(shiroUser), "账号" + shiroUser.getName());
        thread.start();
        thread.join();

    }

    class Task implements Runnable {
        private ShiroUser shiroUser;

        Task(ShiroUser shiroUser) {
            this.shiroUser = shiroUser;
        }

        @Override
        public void run() {
            System.out.println(Thread.currentThread().getName());
            shiroUserMapper.insert(shiroUser);
        }
    }

}

